function checkForm(){ 
    var nametip = checkUserName(); 
    var passtip = checkPassword();   
    return nametip && passtip;
} 
function checkUserName(){
	var username=document.getElementById('userName');
	var errname = document.getElementById('errName'); 
	if(username.value.length == 0){ 
    errname.innerHTML="用户名不能为空"
    errname.className="error"
    return false; 
	}
    else{ 
    errname.innerHTML="OK"
    errname.className="success"; 
    return true; 
    } 
}
function checkPassword(){ 
  var userpasswd = document.getElementById('userPassword'); 
  var errPasswd = document.getElementById('errPassword'); 
  if(userpasswd.value.length == 0){ 
    errPassword.innerHTML="密码不能为空"
    errPassword.className="error"
    return false; 
    }
   else{ 
     errPassword.innerHTML="OK"
     errPassword.className="success"; 
     return true; 
     } 
  } 
while(1){
  if(!checkForm()){
	document.getElementById('submit').disabled=true;
	document.getElementById('submit').value="请查看是否误填";
  }
  else{
	document.getElementById('submit').disabled=false;
	document.getElementById('submit').className="submit";
  }
}